package com.gxa.web_admin.controller.hy;

import com.gxa.common.base.RespResult;
import com.gxa.modules.service.DataStatisticsService;
import com.gxa.web_admin.vo.AnalysisVo;
import com.gxa.web_admin.vo.CommissionVo;
import com.gxa.modules.dto.DataStatisticsDTO;
import com.gxa.web_admin.vo.DetailedVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 数据统计
 */
@Controller
@RequestMapping("/dataStatistics")
public class DataStatisticsController {
    @Autowired
    private DataStatisticsService dataStatisticsService;

    @RequestMapping(value = "/overview", method = RequestMethod.GET)
    @ResponseBody
    public RespResult overview(){
        return dataStatisticsService.overview();
    }

    /**
     * 客户分析/通过时间查找客户分析
     *  @param dateF
     *  @param dateL
     * @return
     */
    @RequestMapping(value = "/analysis", method = RequestMethod.GET)
    @ResponseBody
    public RespResult analysis(String dateF,String dateL){
        return dataStatisticsService.analysis(dateF,dateL);
    }


    /**
     * 跟单统计-按员工
     * @return
     */
    @RequestMapping(value = "/statisticsByEmp", method = RequestMethod.GET)
    @ResponseBody
    public RespResult statisticsByEmp(){
        return dataStatisticsService.statisticsByEmp();
    }

    /**
     * 跟单统计-按部门
     * @return
     */
    @RequestMapping(value = "/statisticsByDept", method = RequestMethod.GET)
    @ResponseBody
    public RespResult statisticsByDept(){
        return dataStatisticsService.statisticsByDept();
    }

    /**
     * 订单统计-按员工
     * @return
     */
    @RequestMapping(value = "/orderStatisticsByEmp", method = RequestMethod.GET)
    @ResponseBody
    public RespResult orderStatisticsByEmp(){
        return dataStatisticsService.orderStatisticsByEmp();
    }

    /**
     * 订单统计-按部门
     * @return
     */
    @RequestMapping(value = "/orderStatisticsByDept", method = RequestMethod.GET)
    @ResponseBody
    public RespResult orderStatisticsByDept(){
        return dataStatisticsService.orderStatisticsByDept();
    }

    /**
     * 合同统计-按员工
     * @return
     */
    @RequestMapping(value = "/aStatisticsByEmp", method = RequestMethod.GET)
    @ResponseBody
    public RespResult aStatisticsByEmp(){
        return dataStatisticsService.aStatisticsByEmp();
    }

    /**
     *合同统计-按部门
     * @return
     */
    @RequestMapping(value = "/aStatisticsByDept", method = RequestMethod.GET)
    @ApiOperation(value = "合同统计-按部门", httpMethod = "GET", response = RespResult.class)
    @ResponseBody
    public RespResult aStatisticsByDept(){
        return dataStatisticsService.aStatisticsByDept();
    }

    /**
     * 售后统计-按员工
     * @return
     */
    @RequestMapping(value = "/afterStatisticsByEmp", method = RequestMethod.GET)
    @ResponseBody
    public RespResult afterStatisticsByEmp(){
        return dataStatisticsService.afterStatisticsByEmp();
    }

    /**
     * 售后统计-按部门
     * @return
     */
    @RequestMapping(value = "/afterStatisticsByDept", method = RequestMethod.GET)
    @ResponseBody
    public RespResult afterStatisticsByDept(){
        return dataStatisticsService.afterStatisticsByDept();
    }

    /**
     * 年度曲线
     * @return
     */
    @RequestMapping(value = "/annualCurve", method = RequestMethod.GET)
    @ResponseBody
    public RespResult annualCurve(){
        return dataStatisticsService.annualCurve();
    }

    /**
     * 详细统计-按员工
     * @return
     */
    @RequestMapping(value = "/detailedByEmp", method = RequestMethod.GET)
    @ApiOperation(value = "详细统计-按员工", httpMethod = "GET", response = RespResult.class)
    @ResponseBody
    public RespResult detailedByEmp(String dataF,String dataL,Integer currentPage, Integer pageSize){
        return dataStatisticsService.detailedByEmp(dataF,dataL,currentPage,pageSize);
    }

    /**
     * 详细数据-按部门
     * @return
     */
    @RequestMapping(value = "/detailedByDept", method = RequestMethod.GET)
    @ApiOperation(value = "详细数据-按部门", httpMethod = "GET", response = RespResult.class)
    @ResponseBody
    public RespResult detailedByDept(String dataF,String dataL,Integer currentPage, Integer pageSize){
        return dataStatisticsService.detailedByDept(dataF,dataL,currentPage,pageSize);
    }

    /**
     * 订单提成
     * @return
     */
    @RequestMapping(value = "/commission", method = RequestMethod.GET)
    @ResponseBody
    public RespResult commission(String dataF,String dataL,Integer currentPage, Integer pageSize){
        return dataStatisticsService.commission(dataF,dataL,currentPage,pageSize);
    }

    /**
     *
     * @return
     */
    @RequestMapping(value = "/commissionByTime", method = RequestMethod.GET)
    @ApiOperation(value = "订单提成-按时间查", httpMethod = "GET", response = RespResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dateF", value = "日期区间前", paramType = "query", dataType = "date", required = true),
            @ApiImplicitParam(name = "dateL", value = "日期区间后", paramType = "query", dataType = "date", required = true)
    })
    @ResponseBody
    public RespResult commissionByTime(){
        List<CommissionVo> list=new ArrayList<>();
        CommissionVo commissionVo=new CommissionVo();
        list.add(commissionVo);
        return RespResult.success(list);
    }
}
